// 资产信息
var assetsColumns = [{
  id: 'no',
  title: '资产编号',
  width: 160,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'type',
  title: '资产类别',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'status',
  title: '目前状态',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'address',
  title: '放置地点',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'username',
  title: '归属者',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'proname',
  title: '归属项目',
  width: 100,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'form',
  title: '来源方式',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'msg',
  title: '资产描述',
  type: 'string',
  columnClass: 'text-left',
}, {
  id: 'operation',
  title: '操作',
  width: 60,
  type: 'string',
  columnClass: 'text-center',
  resolution: function (value, record, column, grid, dataNo, columnNo) {
    var content = '';
    content += '<button class="btn btn-xs btn-success" onclick="editast(' + record.id + ');"><i class="fa fa-edit"></i>  办理</button>';
    // content += '  ';
    // content += '<button class="btn btn-xs btn-primary" onclick="selast(' + record.id + ');"><i class="icon-eye-open"></i>  查看</button>';
    return content;
  }
}];
var assetsOption = {
  lang: 'zh-cn',
  ajaxLoad: false,
  // loadURL:'url',
  exportFileName: '资产信息',
  datas: [{
    no: 'NJSTS201801021800',
    type: '办公',
    status: '闲置',
    address: '南京',
    username: '张三',
    proname: '中国移动',
    form: '借货',
    msg: '资产说明测试数据',
  }, ],
  columns: assetsColumns,
  gridContainer: 'assetsContainer',
  toolbarContainer: 'assetsToolBarContainer',
  tools: '',
  pageSize: 10,
  pageSizeLimit: [10, 15, 20]
};
var assetsGrid = $.fn.dlshouwen.grid.init(assetsOption);
$(function () {
  assetsGrid.load();
});

// 资产查看
function selast(id) {
  window.location.href = "../../proinfo/edit/edit-assets-1.html" + '?id=' + id;
}

// 资产办理
function editast(id) {
  window.location.href = "../../proinfo/edit/edit-assets-2.html" + '?id=' + id;
}

// 资产信息记录
var astlogColumns = [{
  id: 'doTime',
  title: '操作时间',
  width: 160,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'dohistory',
  title: '操作记录',
  type: 'string',
  columnClass: 'text-left',
}, ];
var astlogOption = {
  lang: 'zh-cn',
  ajaxLoad: false,
  // loadURL:'url',
  exportFileName: '资产信息记录',
  datas: [{
    doTime: '9999-99-99 24:00',
    dohistory: '资产管理员张三，转移资产给李四，未确认接收',
  }, ],
  columns: astlogColumns,
  gridContainer: 'astlogContainer',
  toolbarContainer: 'astlogToolBarContainer',
  tools: '',
  pageSize: 10,
  pageSizeLimit: [10, 15, 20]
};
var astlogGrid = $.fn.dlshouwen.grid.init(astlogOption);
$(function () {
  astlogGrid.load();
});


// 资产借货列表
var libraryColumns = [{
  id: 'no',
  title: '资产编号',
  width: 160,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'type',
  title: '资产类别',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'status',
  title: '目前状态',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'address',
  title: '放置地点',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'username',
  title: '归属者',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'proname',
  title: '归属项目',
  width: 100,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'form',
  title: '来源方式',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'msg',
  title: '资产描述',
  type: 'string',
  columnClass: 'text-left',
}, {
  id: 'operation',
  title: '操作',
  width: 130,
  type: 'string',
  columnClass: 'text-center',
  resolution: function (value, record, column, grid, dataNo, columnNo) {
    var content = '';
    content += '<button class="btn btn-xs btn-info" onclick="borrow(' + record.id + ');"><i class="icon-hand-right"></i>  申请</button>';
    content += '  ';
    content += '<button class="btn btn-xs btn-primary" onclick="selb(' + record.id + ');"><i class="icon-eye-open"></i>  查看</button>';
    return content;
  }
}];
var libraryOption = {
  lang: 'zh-cn',
  ajaxLoad: false,
  // loadURL:'url',
  exportFileName: '资产信息',
  datas: [{
    id:1,
    no: 'NJSTS201801021800',
    type: '办公',
    status: '闲置',
    address: '南京',
    username: '张三',
    proname: '中国移动',
    form: '借货',
    msg: '资产说明测试数据',
  }, ],
  columns: libraryColumns,
  gridContainer: 'libraryContainer',
  toolbarContainer: 'libraryToolBarContainer',
  tools: '',
  pageSize: 10,
  pageSizeLimit: [10, 15, 20]
};
var libraryGrid = $.fn.dlshouwen.grid.init(libraryOption);
$(function () {
  libraryGrid.load();
});

// 借货申请
function borrow(id){
  layer.confirm('是否确认申请此资源？', {
    title: '提示信息',
    btn: ['确认', '取消'] //按钮
  }, function () {
    layer.msg('申请成功', {
      icon: 1
    });
  });
}

// 资产查看
function selb(id) {
  window.location.href = "../../proinfo/edit/edit-assets-3.html" + '?id=' + id;
}
